Public Class frmSEARCH_DELIVERY
    Dim fromdate As Date
    Dim todate As Date
    Private Sub btnNew_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNew.Click
        Dim frm As New frmORDER
        If frm.ShowDialog() = Windows.Forms.DialogResult.OK Then
            Dim frm1 As New frmDELIVERY_INFO
            frm1.ShowDialog()

            Dim arName As New ArrayList
            arName.Add("@BILL_CODE")
            arName.Add("@DEL_NAME")
            arName.Add("@DEL_PHONE")
            arName.Add("@DEL_ADDRESS")
            arName.Add("@BILL_DATE")
            arName.Add("@DEL_MAN")
            Dim arVal As New ArrayList
            arVal.Add(frm.BillCode)
            arVal.Add(frm1.txtCustomerName.Text)
            arVal.Add(frm1.txtPhone.Text)
            arVal.Add(frm1.txtAddress.Text)
            arVal.Add(frm1.DeliveryDate)
            arVal.Add(frm1.EMP_CODE)
            BLL.Object_Update_NonResult("BILL_DELIVERY", arName, arVal)
            search()
        End If
    End Sub

    Private Sub btnClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClose.Click
        Me.Close()
    End Sub

    

    Private Sub search()
        Dim arName As New ArrayList
        arName.Add("@fromdate")
        arName.Add("@todate")
        Dim arVal As New ArrayList
        arVal.Add(fromdate)
        arVal.Add(todate)
        GridDelivery.DataSource = BLL.ObjectGetBy("DELIVERY_LOAD", arName, arVal)
    End Sub
    Private Sub btnFrom_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFrom.Click
        Dim FRM As New frmCalendar
        FRM.ShowDialog()
        FromDate = FRM.Calendar2.SelectionRange.Start
        txtFromDate.Text = fromdate.ToString(PublicVariable.DateTimeFormat)
        search()
    End Sub

    Private Sub UiButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UiButton1.Click
        Dim FRM As New frmCalendar
        FRM.ShowDialog()
        todate = FRM.Calendar2.SelectionRange.Start
        txtToDate.Text = todate.ToString(PublicVariable.DateTimeFormat)
        If fromdate > todate Then
            SystemFunction.ShowMessageForm("TO DATE MUST BE GREATER THAN FROM DATE!", "")
            txtToDate.Text = txtFromDate.Text
            todate = fromdate
        End If
        search()
    End Sub

    Private Sub frmSEARCH_DELIVERY_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
        Try
            GC.Collect()
            Me.Dispose()
        Catch ex As Exception

        End Try
    End Sub

    Private Sub frmSEARCH_DELIVERY_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        PublicFunction.NewFormLoad(Me)
        fromdate = Now.Date
        todate = Now.Date
        txtFromDate.Text = fromdate.ToString(PublicVariable.DateTimeFormat)
        txtToDate.Text = todate.ToString(PublicVariable.DateTimeFormat)
        search()
        Me.GridDelivery.RootTable.Columns("BILL_TOTAL").FormatString = PublicVariable.NumberFormatString
        Me.GridDelivery.RootTable.Columns("BILL_DATE").FormatString = PublicVariable.DateTimeFormat
        Me.GridDelivery.RootTable.Columns("BILL_AMT").FormatString = PublicVariable.NumberFormatString
        Me.GridDelivery.RootTable.Columns("BILL_TAX_AMT").FormatString = PublicVariable.NumberFormatString
        Me.GridDelivery.RootTable.Columns("BILL_DCAMT").FormatString = PublicVariable.NumberFormatString
    End Sub

    Private Sub btnSelect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSelect.Click
        Dim frm As New frmORDER
        frm.BillCode = Me.GridDelivery.GetValue("BILL_CODE")
        If frm.ShowDialog() = Windows.Forms.DialogResult.OK Then
            search()
        End If
    End Sub
End Class